--TEST--
string MySQLndUhConnection::charsetName(resource $connection)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function charsetName($res) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::charsetName($res));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function charsetName($res) {
			return 12345;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function charsetName($res) { }
	}

	class proxy4 extends MySQLndUhConnection {
		public function charsetName($res) {
			return str_repeat('a', 4096);
		}
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	$org = mysqli_character_set_name($conn);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	if (($tmp = mysqli_character_set_name($conn)) != $org)
		printf("[001] Character set has changed from '%s' to '%s'\n", $org, $tmp);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	var_dump(mysqli_character_set_name($conn));

	mysqlnd_uh_set_connection_proxy(new proxy2());
	var_dump(mysqli_character_set_name($conn));

	mysqlnd_uh_set_connection_proxy(new proxy3());
	var_dump(mysqli_character_set_name($conn));

	print "done!";
?>
--EXPECTF--
proxy::charsetName(array (
  0 => NULL,
))
string(6) "latin1"

Warning: mysqli_character_set_name(): (MySQLnd User Handler) The method MySQLndUhConnection::charsetName() should not return a string longer than MYSQLND_UH_CHARSET_NAME_LENGTH - 1 characters. The return value will be trimmed in %s on line %d
string(63) "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Warning: mysqli_character_set_name(): (MySQLnd User Handler) The method MySQLndUhConnection::charsetName() did not return a string value as it should in %s on line %d

Fatal error: mysqli_character_set_name(): (MySQLnd User Handler) The method MySQLndUhConnection::charsetName() has either returned an empty string or nothing at all. An empty string may crash PHP in %s on line %d